package main

import (
	_ "embed"
	"encoding/json"
	"os"
	"strings"
)

//go:embed lang.json
var langData []byte

var lang string

var langMap = make(map[string]map[string]string)

func init() {
	lang = os.Getenv("LANG")
	if strings.HasPrefix(lang, "zh_") {
		lang = "zh"
	} else {
		lang = "other"
	}
	json.Unmarshal(langData, &langMap)
}

func T(s string) string {
	if lang == "zh" {
		return s
	}
	ret, ok := langMap[lang][s]
	if ok {
		return ret
	} else {
		return s
	}
}
